app.controller('enterpwdPageCtrl', function($scope, $interval, $cordovaCamera, PopupService, $http, $myconfig, $state, $stateParams, $ionicLoading, $ionicConfig, $mydialog) {
    //接收参数
    // console.log($stateParams.mes);
    $scope.lost_password = JSON.parse($stateParams.mes);

    //发送至服务器更新账户
    $scope.goLogin = function() {
        if ($scope.lost_password.password.length < 7) {
            $scope.err = '密码不得小于八位数，不得大于20位';
            $mydialog.fail($scope);
            return;
        } else if ($scope.lost_password.password != $scope.lost_password.comf_password) {
            $scope.err = '两次密码输入不一致，请重新输入';
            $mydialog.fail($scope);
            return;
        }
        $http.post($myconfig.api.base_host + '/users/lost_password', {
            "mobile": $scope.lost_password.mobile,
            "password": $scope.lost_password.password,
            "comf_password": $scope.lost_password.comf_password
        }).then(function(res) {
            if (res.data.success) {
                $scope.success_text = '修改成功，请登录重试';
                $mydialog.success($scope);
                $state.go('app.login');
            } else {
                $scope.err = res.data.data;
                $mydialog.fail($scope);
            }
        });
    };

    $scope.$on('$ionicView.enter', function() {

        $ionicConfig.views.swipeBackEnabled(false);

    });
});
